# -*- coding: utf-8 -*-
"""
@Time    : 2021/10/9 18:51
@Author  : Leibuyun
@File    : 3.15 字符串转换为日期.py
"""

from datetime import datetime

# 字符串-->datetime对象
text = '2012-9-20'
y = datetime.strptime(text, '%Y-%m-%d')  # 性能较差
z = datetime.now()
diff = z - y
print(diff)

# datetime-->字符串
nice_z = datetime.strftime(z, '%A %B %d, %Y')
print(nice_z)